import 'package:flutter/material.dart';

class AppBarDemoPage extends StatelessWidget {
  const AppBarDemoPage({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    // 步骤1: 在Scaffold外层包裹一个DefaultTabController组件(必须要配置length参数)
    return DefaultTabController(
      length: 2,
      child: Scaffold(
        appBar: AppBar(
          centerTitle: true,
          title: Text("顶部导航顶"),
          backgroundColor: Colors.purple,
          actions: <Widget>[
            IconButton(
              icon: Icon(Icons.menu),
              onPressed: () {
                print("object");
              },
            ),
            IconButton(
              icon: Icon(Icons.menu),
              onPressed: () {
                print("object");
              },
            )
          ],
          // 步骤二, 新增bottom参数, 参考如下
          bottom: TabBar(
            tabs: <Widget> [
              Tab(text: "热门"),
              Tab(text: "网红"),
            ]
          ),
        ),
        body: TabBarView(
          children: <Widget>[
            ListView(
              children: <Widget>[
                ListTile(
                  title: Text("这是1个tab")
                ),
                ListTile(
                  title: Text("这是2个tab")
                ),
                ListTile(
                  title: Text("这是3个tab")
                ),
                ListTile(
                  title: Text("这是4个tab")
                )
              ],
            ),
            Container(
              child: Text("我就想放个文本"),
            )
          ],
        )
      )
    );
  }
}